package de.cbf.cam.locations.model;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import de.cbf.cam.locations.model.controller.ControllerLocations;
import de.cbf.cam.locations.model.test.TestDataProvider;
import de.cbf.cam.locations.model.ui.CompositeLocationTree;

public class ViewLocationTree extends ViewPart {
	public static final String ID = "de.cbf.cam.locations.model.view.locationTree";

	private ControllerLocations controller;
	private CompositeLocationTree tree;
	
	/**
	 * This is a callback 
	 */
	public void createPartControl(Composite parent) {
		tree = new CompositeLocationTree(parent, SWT.NONE);
		tree.setLayoutData(new GridData(GridData.FILL_BOTH));
		controller = new ControllerLocations();
		controller.setView(tree);
		controller.setLocations(TestDataProvider.provideTestData());
	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		tree.setFocus();
	}
	
	public Composite getContentComposite(){
		return tree;
	}
	/**
	 * @return the controller
	 */
	public ControllerLocations getController() {
		return controller;
	}
}